rec->serial = serial++;
if (rec->type == 0x12) { /* image */
- if (strstr(wpt->icon_descr, ":\\")) {
- rec->image_name = xstrdup(wpt->icon_descr);
+ if (wpt->icon_descr.contains(":\\")) {
+ rec->image_name = xstrdup(wpt->icon_descr.toUtf8().data());
rec->height = -244;
rec->width = -1;
}
}
- if (!rec->image_name && wpt->icon_descr) {
- FindIconByName((char*)(void*)wpt->icon_descr, &rec->guid);
+ if (!rec->image_name && !wpt->icon_descr.isNull()) {
+// FIXME: WTH?
+char* t = xstrdup(wpt->icon_descr.toUtf8().data());
+ FindIconByName(t, &rec->guid);
+xfree(t);
}
Write_AN1_Waypoint(outfile, rec);
return (node) ? 1 : 0;
}
+int
+avltree_find(const avltree_t* tree, const QString key, const void** data)
+{
+ const char*t = xstrdup(key.toUtf8().data());
+ int r = avltree_find(tree, key, data);
+ xfree(t);
+ return r;
+
+}
+
/* Get the first (the MIN-) entry of the tree */
/* Find key [key] in tree */
int avltree_find(const avltree_t* tree, const char* key, const void** data);
+int avltree_find(const avltree_t* tree, const QString key, const void** data);
/* Get the first (the MIN-) entry of the tree */
const char* avltree_first(const avltree_t* tree, const void** data);
}
static const char*
-get_bcr_icon_from_icon_descr(const char* icon_descr)
+get_bcr_icon_from_icon_descr(QString icon_descr)
{
const char* result = BCR_DEF_ICON;
- if (icon_descr) {
+ if (!icon_descr.isNull()) {
bcr_icon_mapping_t* m;
for (m = bcr_icon_mapping; (m->bcr_name); m++) {
if (! m->mps_name) {
continue;
}
- if (case_ignore_strcmp(icon_descr, m->mps_name) == 0) {
+ if (icon_descr.compare(m->mps_name, Qt::CaseInsensitive) == 0) {
result = m->bcr_name;
break;
}
};
static unsigned int
-bushnell_get_icon_from_name(const char* name)
+bushnell_get_icon_from_name(QString name)
{
icon_mapping_t* t;
+
+ if (name.isNull()) {
+ name = "Waypoint";
+ }
+
for (t = bushnell_icons; t->icon > 0; t++) {
- if (0 == case_ignore_strcmp(name, t->icon)) {
+ if (0 == name.compare(t->icon, Qt::CaseInsensitive)) {
return t->symbol;
}
}
file_out = gbfopen_le(fname, "wb", MYNAME);
gbfputint32(wpt->latitude * 10000000, file_out);
gbfputint32(wpt->longitude * 10000000, file_out);
- gbfputc(bushnell_get_icon_from_name(wpt->icon_descr ? wpt->icon_descr :
- "Waypoint"), file_out);
+ gbfputc(bushnell_get_icon_from_name(wpt->icon_descr), file_out);
gbfputc(0x01, file_out); // Proximity alarm. 1 == "off", 3 == armed.
ident = mkshort(mkshort_handle, wpt->shortname);
xfree(desc_short);
xfree(desc_long);
- if (appendicon && wpt->icon_descr) {
+ if (appendicon && !wpt->icon_descr.isNull()) {
int left = DESCSZ - strlen(vdata);
- int ilen = strlen(wpt->icon_descr);
+ int ilen = strlen(wpt->icon_descr.toUtf8().data());
if (ilen && left > (ilen+3)) {
strcat(vdata, " (");
- strcat(vdata, wpt->icon_descr);
+ strcat(vdata, wpt->icon_descr.toUtf8().data());
strcat(vdata, ")");
}
}
#endif
switch (col) {
case 0:
- wpt->icon_descr = xstrdup(c);
- wpt->wpt_flags.icon_descr_is_dynamic = 1;
+ wpt->icon_descr = c;
break;
case 1:
break; /* Text postion */
if ((wpt->icon_descr != NULL) || (wpt->wpt_flags.proximity) || \
(option_icon != NULL)) {
- char* icon = option_icon;
-
- if (wpt->icon_descr != NULL) {
- icon = (char*) wpt->icon_descr;
- }
-
gbfprintf(fout, "w %s,0,0.0,16777215,255,1,7,,%.1f\n",
- (icon != NULL) ? icon : "Waypoint",
+ wpt->icon_descr.isNull() ? "Waypoint" : wpt->icon_descr.toUtf8().data(),
WAYPT_GET(wpt, proximity, 0));
}
xfree(name);
wpt_tmp->shortname = xstrndup(rec->name, sizeof(rec->name));
wpt_tmp->icon_descr = coto_get_icon_descr(pdb_rec->category, app);
- if (wpt_tmp->icon_descr) {
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
- }
if ((c = strstr(rec->notes, "\nNotes:\n"))) { /* remove our contruct */
wpt_tmp->notes = xstrdup(c + 8);
xfree(notes);
}
- if (wpt->icon_descr) {
+ if (!wpt->icon_descr.isNull()) {
for (i = 1; i < 16; i++)
- if (!strncmp(wpt->icon_descr, ai->categories[i], 16)) {
+ if (!strncmp(wpt->icon_descr.toUtf8().data(), ai->categories[i], 16)) {
cat=i;
break;
}
// We have a new one
if (ai->maxid<15) {
i = ++ai->maxid;
- snprintf(ai->categories[i], 16, "%s", wpt->icon_descr);
+ snprintf(ai->categories[i], 16, "%s", wpt->icon_descr.toUtf8().data());
cat = ai->ids[i] = i;
} else {
// We're full!
- warning(MYNAME ": Categories full. Category '%s' written as %s.\n", wpt->icon_descr, zerocat?zerocat:"Not Assigned");
+ warning(MYNAME ": Categories full. Category '%s' written as %s.\n", wpt->icon_descr.toUtf8().data(), zerocat?zerocat:"Not Assigned");
}
}
}
break;
case XT_ICON_DESCR:
wpt->icon_descr = csv_stringtrim(s, "", 0);
- wpt->wpt_flags.icon_descr_is_dynamic = 1;
break;
/* LATITUDE CONVERSIONS**************************************************/
break;
case XT_ICON_DESCR:
writebuff(buff, fmp->printfc,
- (wpt->icon_descr && *wpt->icon_descr) ?
- wpt->icon_descr : fmp->val);
+ (!wpt->icon_descr.isNull()) ?
+ wpt->icon_descr.toUtf8().data() : fmp->val);
break;
/* LATITUDE CONVERSION***********************************************/
class wp_flags {
public:
wp_flags() :
- icon_descr_is_dynamic(0),
shortname_is_synthetic(0),
cet_converted(0),
fmt_use(0),
depth(0),
is_split(0),
new_trkseg(0) {}
- unsigned int icon_descr_is_dynamic:1;
unsigned int shortname_is_synthetic:1;
unsigned int cet_converted:1; /* strings are converted to UTF8; interesting only for input */
unsigned int fmt_use:1; /* lightweight "extra data" */
url_next(NULL),
url(NULL),
url_link_text(NULL),
- icon_descr(NULL),
#if NEWTIME
// creation_time(QDateTime::fromTime_t(0)),
#else
char* url_link_text;
wp_flags wpt_flags;
- const char* icon_descr;
+ QString icon_descr;
#if NEWTIME
gpsbabel::DateTime creation_time;
#else
wp->altitude = f;
}
wp->icon_descr = waypoint_symbol(p->symbol);
- if (wp->icon_descr) {
- wp->icon_descr = xstrdup(wp->icon_descr);
- }
+// if (!wp->icon_descr.isNull()) {
+// wp->icon_descr = wp->icon_descr;
+// }
if (p->name_size && p->name[0]) {
wp->description = xstrdup(p->name);
}
case gt_ape:
break;
}
- if (0 == strcmp(wp->icon_descr, "Geocache Found")) {
+ if (0 == (wp->icon_descr.compare("Geocache Found"))) {
gc_sym = 124;
}
if (wp->description) {
if (gc_sym && opt_gcsym && atoi(opt_gcsym)) {
gbfprintf(fd, "%s\n", waypoint_symbol(gc_sym));
*symbol = gc_sym;
- } else if (wp->icon_descr) {
- gbfprintf(fd, "%s\n", wp->icon_descr);
+ } else if (!wp->icon_descr.isNull()) {
+ gbfprintf(fd, "%s\n", wp->icon_descr.toUtf8().data());
}
switch (wp->gc_data->container) {
case gc_micro:
le_write_float(p->elevation, elev);
if (symbol < 0) {
symbol = 0;
- if (wp->icon_descr) {
- symbol = waypoint_symbol_index(wp->icon_descr);
+ if (!wp->icon_descr.isNull()) {
+ symbol = waypoint_symbol_index(wp->icon_descr.toUtf8().data());
}
}
p->symbol = symbol;
break;
case 7:
wpt_tmp->icon_descr = gbfgetpstr(file_in);;
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
break;
case 8: /* NULL Terminated (vs. pascal) descr */
wpt_tmp->notes = gbfgetcstr(file_in);
gbfputc(3, file_out);
gbfputpstr(wpt->description, file_out);
}
- if (wpt->icon_descr) {
+ if (!wpt->icon_descr.isNull()) {
gbfputc(7, file_out);
gbfputpstr(wpt->icon_descr, file_out);
}
case WAYPT__OFS + 2:
wpt->icon_descr = gt_find_desc_from_icon_number(
atoi(cin), PCX, &dyn);
- wpt->wpt_flags.icon_descr_is_dynamic = dyn;
break;
case WAYPT__OFS + 4:
cdata++;
wpt->icon_descr = gt_find_desc_from_icon_number(
atoi(cdata), PCX, &dyn);
- wpt->wpt_flags.icon_descr_is_dynamic = dyn;
}
waypt_add(wpt);
break;
};
static const char* d103_symbol_from_icon_number(unsigned int n);
-static int d103_icon_number_from_symbol(const char* s);
+static int d103_icon_number_from_symbol(QString s);
static void
int dyn = 0;
wpt_tmp->icon_descr = gt_find_desc_from_icon_number(
way[i]->smbl, PCX, &dyn);
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = dyn;
}
/*
* If a unit doesn't store altitude info (i.e. a D103)
}
static int
-d103_icon_number_from_symbol(const char* s)
+d103_icon_number_from_symbol(QString s)
{
unsigned int i;
- if (NULL == s) {
+ if (s.isNull()) {
return 0;
}
for (i = 0; i < sizeof(d103_icons) / sizeof(d103_icons[0]); i++) {
- if (0 == case_ignore_strcmp(s, d103_icons[i])) {
+ if (0 == (s.compare(d103_icons[i]), Qt::CaseInsensitive)) {
return i;
}
}
case MAPSOURCE:
case GDB:
if (icon == i->mpssymnum) {
- return (char*)i->icon;
+ return i->icon;
}
break;
case PCX:
case GARMIN_SERIAL:
if (icon == i->pcxsymnum) {
- return (char*)i->icon;
+ return i->icon;
}
break;
default:
return DEFAULT_ICON_DESCR;
}
-int gt_find_icon_number_from_desc(const char* desc, garmin_formats_e garmin_format)
+int gt_find_icon_number_from_desc(const QString desc, garmin_formats_e garmin_format)
{
static int find_flag = 0;
icon_mapping_t* i;
int def_icon = DEFAULT_ICON_VALUE;
int n;
- if (!desc) {
+ if (desc.isNull()) {
return def_icon;
}
* If we were given a numeric icon number as a description
* (i.e. 8255), just return that.
*/
- n = atoi(desc);
+ n = desc.toInt();
if (n) {
return n;
}
- if (0 == case_ignore_strncmp(desc, "Custom ", 7)) {
+ if (desc.startsWith("Custom ", Qt::CaseInsensitive)) {
int base = 0;
if (garmin_format == GDB) {
base = 500;
base = 7680;
}
if (base) {
- n = atoi(&desc[7]);
+ n = desc.mid(7).toInt();
return n + base;
}
}
for (i = garmin_smart_icon_table; global_opts.smart_icons && i->icon; i++) {
- if (case_ignore_strcmp(desc,i->icon) == 0) {
+ if (desc.compare(i->icon, Qt::CaseInsensitive) == 0) {
switch (garmin_format) {
case MAPSOURCE:
case GDB:
}
}
for (i = garmin_icon_table; i->icon; i++) {
- if (case_ignore_strcmp(desc,i->icon) == 0) {
+ if (desc.compare(i->icon, Qt::CaseInsensitive) == 0) {
switch (garmin_format) {
case MAPSOURCE:
case GDB:
const char* prefixes[] = {
"White ", "Red ", "Green ", "Blue ", "Black ", NULL
};
-
+ // Rewrite "Green Square" to "Square, Green".
for (prefix = prefixes; *prefix != NULL; prefix++) {
- int len = strlen(*prefix);
-
- if (case_ignore_strncmp(desc, *prefix, len) == 0) {
- char buff[64];
- int result;
-
- snprintf(buff, sizeof(buff), "%s, %s", &desc[len], *prefix);
- rtrim(buff);
+ if (desc.startsWith(*prefix, Qt::CaseInsensitive)) {
+ QString buff = desc;
+ buff.replace(*prefix, "");
+ buff.append(", ");
+ buff.append(*prefix);
+ buff = buff.trimmed();
find_flag = 1;
- result = gt_find_icon_number_from_desc(buff, garmin_format);
+ int result = gt_find_icon_number_from_desc(buff, garmin_format);
find_flag = 0;
return result;
}
gbuint32
-gt_color_value(const int garmin_index)
+gt_color_value(const unsigned int garmin_index)
{
if ((garmin_index >= 0) && (garmin_index < GT_COLORS_CT)) {
return gt_colors[garmin_index].rgb;
}
const char*
-gt_color_name(const int garmin_index)
+gt_color_name(const unsigned int garmin_index)
{
if ((garmin_index >= 0) && (garmin_index < GT_COLORS_CT)) {
return gt_colors[garmin_index].name;
typedef enum {MAPSOURCE, PCX, GARMIN_SERIAL, GDB} garmin_formats_e;
const char* gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int* dynamic);
-int gt_find_icon_number_from_desc(const char* desc, garmin_formats_e garmin_format);
+int gt_find_icon_number_from_desc(const QString desc, garmin_formats_e garmin_format);
extern icon_mapping_t garmin_icon_table[];
const char* gt_get_mps_grid_longname(const grid_type grid, const char* module);
int gt_lookup_datum_index(const char* datum_str, const char* module);
const char* gt_get_mps_datum_name(const int datum_index);
-gbuint32 gt_color_value(const int garmin_index);
+gbuint32 gt_color_value(const unsigned int garmin_index);
gbuint32 gt_color_value_by_name(const char* name);
int gt_color_index_by_name(const char* name);
int gt_color_index_by_rgb(const int rgb);
-const char* gt_color_name(const int garmin_index);
+const char* gt_color_name(const unsigned int garmin_index);
#endif
}
static void
-print_string(const char* fmt, const QString string)
+print_string(const char* fmt, QString string)
{
print_string(fmt, string.toUtf8().data());
}
i = gt_find_icon_number_from_desc(str, GDB);
GMSD_SET(icon, i);
wpt->icon_descr = gt_find_desc_from_icon_number(i, GDB, &dynamic);
- wpt->wpt_flags.icon_descr_is_dynamic = dynamic;
break;
case 12:
GMSD_SETSTR(facility, str);
return (len + 1);
}
+int
+gbfputpstr(const QString s, gbfile* file)
+{
+ const char *t = s.toUtf8().data();
+ int r = gbfputpstr(t, file);
+ xfree(t);
+ return r;
+}
+
/* Much more higher level functions */
gbsize_t
int gbfputcstr(const char* s, gbfile* file); // write string including '\0'
int gbfputcstr(const QString s, gbfile* file); // write string including '\0'
int gbfputpstr(const char* s, gbfile* file); // write as pascal string
+int gbfputpstr(const QString s, gbfile* file); // write as pascal string
gbsize_t gbfcopyfrom(gbfile* file, gbfile* src, gbsize_t count);
}
res->icon_descr = gt_find_desc_from_icon_number(icon, GDB, &dynamic);
- res->wpt_flags.icon_descr_is_dynamic = dynamic;
#if GDB_DEBUG
DBG(GDB_DBG_WPTe, icon != GDB_DEF_ICON)
icon = GMSD_GET(icon, -1);
if (icon < 0) {
- if (wpt->icon_descr) {
- icon = gt_find_icon_number_from_desc(wpt->icon_descr, GDB);
- } else {
+ if (wpt->icon_descr.isNull()) {
icon = GDB_DEF_ICON;
+ } else {
+ icon = gt_find_icon_number_from_desc(wpt->icon_descr, GDB);
}
}
void wpt_type(const char* args, const char** unused)
{
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
- wpt_tmp->icon_descr = xstrdup(args);
+ wpt_tmp->icon_descr = args;
}
void wpt_coord(const char* args, const char** attrv)
wpt->longitude = lon;
wpt->altitude = alt;
wpt->icon_descr = category;
- wpt->wpt_flags.icon_descr_is_dynamic = 1;
if (gid[0]) {
wpt->shortname = xstrdup(gid);
/* 52 */ "Mystery or puzzle Cache",
};
-static const char*
+static const QString
geoniche_icon_to_descr(const int no)
{
const char* result = NULL;
GPS_Math_DegMin_To_Deg(londeg, lon, &waypt->longitude);
waypt->icon_descr = geoniche_icon_to_descr(icon_nr);
- if (waypt->icon_descr != NULL) {
- waypt->wpt_flags.icon_descr_is_dynamic = 1;
- }
-
waypt_add(waypt);
}
}
static int
wpt2icon(const waypoint* wpt)
{
- const char* desc = wpt->icon_descr;
+ QString desc = wpt->icon_descr;
- if (!desc) {
+ if (desc.isNull()) {
return 0;
- } else if (strstr(desc, "reg")) {
+ } else if (desc.contains("reg")) {
return 43;
- } else if (strstr(desc, "trad")) {
+ } else if (desc.contains("trad")) {
return 43;
- } else if (strstr(desc, "multi")) {
+ } else if (desc.contains("multi")) {
return 44;
- } else if (strstr(desc, "offset")) {
+ } else if (desc.contains("offset")) {
return 44;
- } else if (strstr(desc, "virt")) {
+ } else if (desc.contains("virt")) {
return 45;
- } else if (strstr(desc, "loca")) {
+ } else if (desc.contains("loca")) {
return 45;
- } else if (strstr(desc, "event")) {
+ } else if (desc.contains("event")) {
return 46;
- } else if (strstr(desc, "lett")) {
+ } else if (desc.contains("lett")) {
return 47;
- } else if (strstr(desc, "hyb")) {
+ } else if (desc.contains("hyb")) {
return 47;
- } else if (strstr(desc, "unk")) {
+ } else if (desc.contains("unk")) {
return 48;
- } else if (strstr(desc, "cam")) {
+ } else if (desc.contains("cam")) {
return 49;
}
WAYPT_SET(wpt_tmp, depth, fi.f);
fi.i = le_read32(&rec->wpt.d108.dist);
WAYPT_SET(wpt_tmp, proximity, fi.f);
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 0;
wpt_tmp->icon_descr = gt_find_desc_from_icon_number((rec->wpt.d108.smbl[1] << 8) + rec->wpt.d108.smbl[0], PCX, NULL);
waypt_add(wpt_tmp);
break;
gpsutil_disp(const waypoint* wpt)
{
double lon,lat;
- const char* icon_token;
+ QString icon_token;
char* tdesc = xstrdup(wpt->description);
icon_token = mag_find_token_from_descr(wpt->icon_descr);
(wpt->altitude < 0.0)) ? 0 : wpt->altitude,
'm',
wpt->description ? tdesc : "",
- icon_token);
+ icon_token.toUtf8().data());
xfree(tdesc);
}
case tt_wpt_sym:
case tt_rte_rtept_sym:
case tt_trk_trkseg_trkpt_sym:
- wpt_tmp->icon_descr = xstrdup(cdatastrp);
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
+ wpt_tmp->icon_descr = cdatastrp;
break;
case tt_wpt_time:
case tt_trk_trkseg_trkpt_time:
}
}
-int icon_from_descr(const char* descr)
+int icon_from_descr(QString descr)
{
- if (descr) {
- int i;
- for (i = 0; icon_descr[i]; i++)
- if (strcmp(icon_descr[i], descr) == 0) {
- return i;
- }
+ for (int i = 0; icon_descr[i]; i++) {
+ if (descr.compare(icon_descr[i]) == 0) {
+ return i;
+ }
}
return 48;
}
void
gtc_wpt_icon(const char* args, const char** unused)
{
- wpt_tmp->icon_descr = xstrdup(args);
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
+ wpt_tmp->icon_descr = args;
}
void
static
void ht_sym(const char* args, const char** unused)
{
- wpt_tmp->icon_descr = xstrdup(args);
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
+ wpt_tmp->icon_descr = args;
}
static
hum.icon = 255;
// Icon....
- if (wpt->icon_descr) {
+ if (!wpt->icon_descr.isNull()) {
for (i = 0; i < num_icons; i++) {
- if (!case_ignore_strcmp(wpt->icon_descr, humminbird_icons[i])) {
+ if (!wpt->icon_descr.compare(humminbird_icons[i], Qt::CaseInsensitive)) {
hum.icon = i;
break;
}
char* match;
int j;
xasprintf(&match, "*%s*", humminbird_icons[i]);
- j = case_ignore_str_match(wpt->icon_descr, match);
+ j = wpt->icon_descr.compare(match, Qt::CaseInsensitive);
xfree(match);
if (j != 0) {
hum.icon = i;
void wpt_icon(const char* args, const char** unused)
{
if (wpt_tmp) {
- wpt_tmp->icon_descr = xstrdup(args);
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
+ wpt_tmp->icon_descr = args;
}
}
static void kml_waypt_pr(const waypoint* waypointp)
{
- const char* icon;
+ QString icon;
#if 0 // Experimental
if (realtime_positioning) {
// Icon - but only if it looks like a URL.
icon = opt_deficon ? opt_deficon : waypointp->icon_descr;
- if (icon && strstr(icon, "://")) {
+ if (icon.contains("://")) {
kml_write_xml(1, "<Style>\n");
kml_write_xml(1, "<IconStyle>\n");
kml_write_xml(1, "<Icon>\n");
- kml_write_xml(0, "<href>%s</href>\n", icon);
+ kml_write_xml(0, "<href>%s</href>\n", icon.toUtf8().data());
kml_write_xml(-1, "</Icon>\n");
kml_write_xml(-1, "</IconStyle>\n");
kml_write_xml(-1, "</Style>\n");
}
int
-lowranceusr_find_icon_number_from_desc(const char* desc)
+lowranceusr_find_icon_number_from_desc(QString desc)
{
const lowranceusr_icon_mapping_t* i;
int n;
- if (!desc) {
+ if (desc.isNull()) {
return DEF_ICON;
}
* If we were given a numeric icon number as a description
* (i.e. 8255), just return that.
*/
- n = atoi(desc);
+ n = desc.toInt();
if (n) {
return n;
}
for (i = lowranceusr_icon_value_table; i->icon; i++) {
- if (case_ignore_strcmp(desc,i->icon) == 0) {
+ if (desc.compare(i->icon,Qt::CaseInsensitive) == 0) {
return i->value;
}
}
/* Symbol ID */
wpt_tmp->icon_descr = lowranceusr_find_desc_from_icon_number(gbfgetint32(file_in));
- if (!wpt_tmp->icon_descr[0]) {
+ if (wpt_tmp->icon_descr.isNull()) {
char nbuf[10];
snprintf(nbuf, sizeof(nbuf), "%d", le_read32(buff));
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
- wpt_tmp->icon_descr = xstrdup(nbuf);
+ wpt_tmp->icon_descr = nbuf;
}
/* Waypoint Type (USER, TEMPORARY, POINT_OF_INTEREST) */
gbfputint32(Time, file_out);
- if (get_cache_icon(wpt) && wpt->icon_descr && (strcmp(wpt->icon_descr, "Geocache Found") != 0)) {
+ if (get_cache_icon(wpt) && wpt->icon_descr.compare("Geocache Found") == 0) {
SymbolId = lowranceusr_find_icon_number_from_desc(get_cache_icon(wpt));
} else {
SymbolId = lowranceusr_find_icon_number_from_desc(wpt->icon_descr);
{
int latmm = lat_deg_to_mm(wpt->latitude);
int lonmm = lon_deg_to_mm(wpt->longitude);
- int icon = wpt->icon_descr ?
+ int icon = !wpt->icon_descr.isNull() ?
lowranceusr_find_icon_number_from_desc(wpt->icon_descr) :
10003;
const char* icon;
} icon_mapping_t;
-const char* mag_find_descr_from_token(const char* token);
-const char* mag_find_token_from_descr(const char* icon);
+QString mag_find_descr_from_token(const char* token);
+QString mag_find_token_from_descr(QString icon);
unsigned int mag_checksum(const char* const buf);
char* m330_cleanse(char* istring);
}
}
-const char*
+QString
mag_find_descr_from_token(const char* token)
{
icon_mapping_t* i = icon_mapping;
return icon_mapping[0].icon;
}
-const char*
-mag_find_token_from_descr(const char* icon)
+QString
+mag_find_token_from_descr(QString icon)
{
icon_mapping_t* i = icon_mapping;
}
for (i = icon_mapping; i->token; i++) {
- if (case_ignore_strcmp(icon, i->icon) == 0) {
+ if (icon.compare(i->icon, Qt::CaseInsensitive) == 0) {
return i->token;
}
}
int lon_deg, lat_deg;
char obuf[200];
char ofmtdesc[200];
- const char* icon_token=NULL;
+ QString icon_token;
char* owpt;
char* odesc;
char* isrc = NULL;
wpt_len,
owpt,
odesc,
- icon_token);
+ icon_token.toUtf8().data());
mag_writemsg(obuf);
xfree(owpt);
xfree(odesc);
char obuff[256];
char buff1[64], buff2[64];
char* pbuff, *owpt;
- const char* icon_token;
+ QString icon_token;
int i, numlines, thisline;
/* count waypoints for this route */
}
owpt = mag_cleanse(owpt);
- sprintf(pbuff, "%s,%s", owpt, icon_token);
+ sprintf(pbuff, "%s,%s", owpt, icon_token.toUtf8().data());
xfree(owpt);
static void
mapsend_waypt_pr(const waypoint* waypointp)
{
- unsigned char c;
+ unsigned int c = 0;
double falt;
static int cnt = 0;
- const char* iconp = NULL;
const char* sn = global_opts.synthesize_shortnames ?
mkshort_from_wpt(mkshort_handle, waypointp) :
waypointp->shortname;
/* #, icon, status */
gbfputint32(++cnt, mapsend_file_out);
+
- if (waypointp->icon_descr) {
+ QString iconp;
+ if (!waypointp->icon_descr.isNull()) {
iconp = mag_find_token_from_descr(waypointp->icon_descr);
- if (1 == strlen(iconp)) {
- c = iconp[0] - 'a';
+ if (1 == iconp.size()) {
+ c = iconp[0].toAscii() - 'a';
} else {
- c = iconp[1] - 'a' + 26;
+ c = iconp[1].toAscii() - 'a' + 26;
}
} else {
c = 0;
}
if (get_cache_icon(waypointp)) {
iconp = mag_find_token_from_descr(get_cache_icon(waypointp));
- if (1 == strlen(iconp)) {
- c = iconp[0] - 'a';
+ if (1 == iconp.size()) {
+ c = iconp[0].toAscii() - 'a';
} else {
- c = iconp[1] - 'a' + 26;
+ c = iconp[1].toAscii() - 'a' + 26;
}
}
mapsend_route_disp(const waypoint* waypointp)
{
unsigned char c;
- const char* iconp;
+ QString iconp;
route_wp_count++;
gbfputdbl(waypointp->longitude, mapsend_file_out);
gbfputdbl(-waypointp->latitude, mapsend_file_out);
- if (waypointp->icon_descr) {
+ if (!waypointp->icon_descr.isNull()) {
iconp = mag_find_token_from_descr(waypointp->icon_descr);
- if (1 == strlen(iconp)) {
- c = iconp[0] - 'a';
+ if (1 == iconp.size()) {
+ c = iconp[0].toAscii() - 'a';
} else {
- c = iconp[1] - 'a' + 26;
+ c = iconp[1].toAscii() - 'a' + 26;
}
} else {
c = 0;
/* might need to change this to handle version dependent icon handling */
thisWaypoint->icon_descr = gt_find_desc_from_icon_number(icon, MAPSOURCE, &dynamic);
- thisWaypoint->wpt_flags.icon_descr_is_dynamic = dynamic;
/* The following Now done elsewhere since it can be useful to read in and
perhaps not add to the list */
int reclen;
int lat, lon;
int icon;
- char* src = ""; /* default to empty string */
+ const char* src = ""; /* default to empty string */
char* ident;
char* ascii_description;
char zbuf[25];
/* might need to change this to handle version dependent icon handling */
icon = gt_find_icon_number_from_desc(wpt->icon_descr, MAPSOURCE);
-
- if (get_cache_icon(wpt) /* && wpt->icon_descr && (strcmp(wpt->icon_descr, "Geocache Found") != 0)*/) {
+ if (get_cache_icon(wpt)) {
icon = gt_find_icon_number_from_desc(get_cache_icon(wpt), MAPSOURCE);
}
char* rname;
char hdr[20];
char zbuf[20];
- char* src = "";
+ const char* src = "";
char* ident;
waypoint* testwpt;
int lon;
char zbuf[20];
char ffbuf[20];
- char* src = "";
+ const char* src = "";
char* ident;
int reclen;
snprintf(key, sizeof(key), "%d", i);
if (avltree_find(icons, key, (const void**)&name)) {
- wpt->icon_descr = xstrdup(name);
- wpt->wpt_flags.icon_descr_is_dynamic = 1;
- DBG((sobj, "icon = \"%s\"\n", wpt->icon_descr));
+ wpt->icon_descr = name;
+ DBG((sobj, "icon = \"%s\"\n", wpt->icon_descr.toUtf8().data()));
}
#ifdef MMO_DBG
else {
wpt->proximity = wpt2->proximity;
wpt->wpt_flags.proximity = wpt2->wpt_flags.proximity;
- if (wpt2->icon_descr) {
- wpt->icon_descr = xstrdup(wpt2->icon_descr);
- wpt->wpt_flags.icon_descr_is_dynamic = 1;
+ if (!wpt2->icon_descr.isNull()) {
+ wpt->icon_descr = wpt2->icon_descr;
}
}
}
gbfputflt(0, fout);
}
- if (wpt->icon_descr) {
+ if (!wpt->icon_descr.isNull()) {
int i = 0;
while (mmo_icon_value_table[i].icon) {
- if (case_ignore_strcmp(wpt->icon_descr, mmo_icon_value_table[i].icon) == 0) {
+ if (wpt->icon_descr.compare(mmo_icon_value_table[i].icon, Qt::CaseInsensitive) == 0) {
icon = mmo_icon_value_table[i].value;
break;
}
static void (*write_route_end)(const route_head* track) = NULL;
static int
-find_icon_from_descr(const char* descr)
+find_icon_from_descr(QString descr)
{
unsigned int i;
- for (i = 0; descr && i < sizeof(icon_table) / sizeof(const char*); i++) {
- if (strcmp(descr, icon_table[i]) == 0) {
+ for (i = 0; i < sizeof(icon_table) / sizeof(const char*); i++) {
+ if (0 == descr.compare(icon_table[i])) {
return i;
}
}
}
-static char*
+static QString
osm_feature_symbol(const int ikey, const char* value)
{
char* result;
wpt->shortname = xstrdup(str);
} else if ((ikey = osm_feature_ikey(key)) >= 0) {
wpt->icon_descr = osm_feature_symbol(ikey, value);
- wpt->wpt_flags.icon_descr_is_dynamic = 1;
} else if (strcmp(key, "note") == 0) {
if (wpt->notes) {
char* tmp;
osm_write_tag("name", wpt->shortname);
osm_write_tag("note", (wpt->notes) ? wpt->notes : wpt->description);
- if (wpt->icon_descr) {
+ if (!wpt->icon_descr.isNull()) {
osm_disp_feature(wpt);
}
other types, but it at least maintains fidelity for an ozi->ozi
operation. */
if (str && isdigit(str[0])) {
- wpt_tmp->icon_descr = xstrdup(str);
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
+ wpt_tmp->icon_descr = str;
}
break;
case 6:
index++;
- if (wpt->icon_descr && isdigit(wpt->icon_descr[0])) {
- icon = atoi(wpt->icon_descr);
+ if (wpt->icon_descr.toInt()) {
+ icon = wpt->icon_descr.toInt();
}
gbfprintf(file_out,
break;
case 6: /* icon */
if (*str != '\0') {
- wpt_tmp->icon_descr = xstrdup(str);
+ wpt_tmp->icon_descr = str;
}
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
break;
case 7: /* notes */
if (*str != '\0') {
buff = ppdb_strcat(buff, ",", NULL, &len);
/* 6 icon */
- tmp = str_pool_getcpy(wpt->icon_descr, opt_deficon); /* point icon or deficon from options */
+ tmp = str_pool_getcpy(wpt->icon_descr.toUtf8().data(), opt_deficon); /* point icon or deficon from options */
buff = ppdb_strcat(buff, tmp, NULL, &len);
buff = ppdb_strcat(buff, ",", NULL, &len);
/* 7 description */
gbfprintf(psit_file, " %-6s, ", ident);
icon = gt_find_icon_number_from_desc(wpt->icon_descr, PCX);
- if (get_cache_icon(wpt) && wpt->icon_descr && (strcmp(wpt->icon_descr, "Geocache Found") != 0)) {
+ if (get_cache_icon(wpt) && wpt->icon_descr.compare("Geocache Found") != 0) {
icon = gt_find_icon_number_from_desc(get_cache_icon(wpt), PCX);
}
#define RAYMARINE_STD_SYMBOL 3
static int
-find_symbol_num(const char *descr)
+find_symbol_num(const QString descr)
{
- if ((descr != NULL) && (*descr)) {
+ if (!descr.isNull()) {
raymarine_symbol_mapping_t *a;
a = &raymarine_symbols[0];
for (unsigned int i = 0; i < RAYMARINE_SYMBOL_CT; i++, a++) {
- if (case_ignore_strcmp(descr, a->name) == 0) {
+ if (descr.compare(a->name, Qt::CaseInsensitive) == 0) {
return i;
}
- if (a->mps_name && (case_ignore_strcmp(descr, a->mps_name) == 0)) {
+ if (a->mps_name && (descr.compare(a->mps_name, Qt::CaseInsensitive) == 0)) {
return i;
}
}
static void
tiger_disp(const waypoint *wpt)
{
- const char *pin;
+ QString pin;
double lat = wpt->latitude;
double lon = wpt->longitude;
if (iconismarker) {
- pin = wpt->icon_descr ? wpt->icon_descr : "";
- } else if (wpt->icon_descr && strstr(wpt->icon_descr, "-unfound")) {
+ pin = wpt->icon_descr;
+ } else if (wpt->icon_descr.contains("-unfound")) {
pin = unfoundmarker;
} else if (wpt->creation_time > current_time() - 3600 * 24 * thresh_days) {
pin = newmarker;
}
}
- gbfprintf(file_out, "%f,%f:%s", lon, lat, pin);
+ gbfprintf(file_out, "%f,%f:%s", lon, lat, pin.toUtf8().data());
if (!nolabels) {
char *temp = NULL;
char *desc = csv_stringclean(wpt->description, ":");
break;
case fld_symbol:
- wpt->icon_descr = xstrdup(s);
- wpt->wpt_flags.icon_descr_is_dynamic = 1;
+ wpt->icon_descr = s;
break;
case fld_iso_time:
}
}
+static void
+unicsv_print_str(const QString s)
+{
+ char *t = xstrdup(s.toUtf8().data());
+ unicsv_print_str(t);
+ xfree(t);
+}
+
#ifdef UNICSV_GC_READY
static void
unicsv_print_data_time(const time_t atime)
if (wpt->altitude != unknown_alt) {
gb_setbit(&unicsv_outp_flags, fld_altitude);
}
- if (wpt->icon_descr && *wpt->icon_descr) {
+ if (!wpt->icon_descr.isNull()) {
gb_setbit(&unicsv_outp_flags, fld_symbol);
}
if (wpt->description && *wpt->description && (strcmp(shortname, wpt->description) != 0)) {
unicsv_print_str(wpt->notes);
}
if FIELD_USED(fld_symbol) {
- unicsv_print_str((wpt->icon_descr != NULL) ? wpt->icon_descr : "Waypoint");
+ unicsv_print_str(wpt->icon_descr.isNull() ? "Waypoint" : wpt->icon_descr);
}
if FIELD_USED(fld_depth) {
if WAYPT_HAS(wpt, depth) {
(url_next->url) ? xstrdup(url_next->url) : NULL,
(url_next->url_link_text) ? xstrdup(url_next->url_link_text) : NULL);
}
- if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic) {
- tmp->icon_descr = xstrdup(wpt->icon_descr);
- }
+
+ tmp->icon_descr = wpt->icon_descr;
if (wpt->gc_data != &empty_gc_data) {
geocache_data *gc_data = (geocache_data*) xmalloc(sizeof(*gc_data));
xfree(tonuke);
}
}
- if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic) {
- xfree((char *)(void *)wpt->icon_descr);
- }
if (wpt->gc_data != &empty_gc_data) {
geocache_data *gc_data = (geocache_data *)wpt->gc_data;
wpt_tmp->altitude = unknown_alt;
wpt_tmp->fix = fix_unknown;
- wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
if (case_ignore_strncmp(ap_wep,"On",2)==0) {
if (case_ignore_strncmp(ap_type,"AP",2)==0) {
- wpt_tmp->icon_descr = xstrdup(aicicon); /* Infra Closed */
+ wpt_tmp->icon_descr = aicicon; /* Infra Closed */
} else {
- wpt_tmp->icon_descr = xstrdup(ahcicon); /* AdHoc Closed */
+ wpt_tmp->icon_descr = ahcicon; /* AdHoc Closed */
}
} else {
if (case_ignore_strncmp(ap_type,"AP",2)==0) {
- wpt_tmp->icon_descr = xstrdup(aioicon); /* Infra Open */
+ wpt_tmp->icon_descr = aioicon; /* Infra Open */
} else {
- wpt_tmp->icon_descr = xstrdup(ahoicon); /* AdHoc Open */
+ wpt_tmp->icon_descr = ahoicon; /* AdHoc Open */
}
}
}
} else if (strcmp(avp[0], "icon") == 0) {
if (wpt) {
- wpt->icon_descr = xstrdup(avp[1]);
- wpt->wpt_flags.icon_descr_is_dynamic = 1;
+ wpt->icon_descr = avp[1];
}
}
gbfprintf(fout, "%*s<shape type=\"waypoint\"", space++*2, "");
xol_write_string("name", name);
xol_write_string("comment", wpt->notes);
- xol_write_string("icon", wpt->icon_descr);
+ xol_write_string("icon", wpt->icon_descr.toUtf8().data());
if (wpt->creation_time) {
xol_write_time(wpt);
}